<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('行政区域列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								区域名：<input type="text" name="regionName"/>
							</li>

							<li>
								<p>行政级别：</p>
								<select class="" name="regionLevel">
									<option value="" >--请选择--</option>
									<option value="1" >省</option>
									<option value="2" >市</option>
									<option value="3" >区（县）</option>
								</select>
							</li>
							<li hidden>
								归属id：<input type="text" name="pId"/>
							</li>

<!--							<li>-->
<!--								邮政编码：<input type="text" name="postalCode"/>-->
<!--							</li>-->

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:region:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="system:region:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:region:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:region:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
<!--			<div class="col-sm-12 select-table table-striped">-->
<!--				<table id="bootstrap-table" data-mobile-responsive="true"></table>-->
<!--			</div>-->
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-tree-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
	 <script th:inline="javascript">
		 var addFlag = [[${@permission.hasPermi('system:dept:add')}]];
		 var editFlag = [[${@permission.hasPermi('system:dept:edit')}]];
		 var removeFlag = [[${@permission.hasPermi('system:dept:remove')}]];
		 var datas = [[${@dict.getType('sys_normal_disable')}]];
		 var prefix = ctx + "system/region"

		 $(function() {
			 var options = {
				 code: "regionId",
				 parentCode: "pid",
				 uniqueId: "regionId",
				 url: prefix + "/list",
				 createUrl: prefix + "/add/{id}",
				 updateUrl: prefix + "/edit/{id}",
				 removeUrl: prefix + "/remove/{id}",
				 modalName: "部门",
				 columns: [{
					 field: 'selectItem',
					 radio: true
				 },
					 {
						 field: 'regionName',
						 title: '区域名',
						 align: "left"
					 },
					 {
						 field: 'regionLevel',
						 title: '行政级别',
						 align: "left"
					 },
					 {
						 title: '操作',
						 align: 'left',
						 formatter: function(value, row, index) {
							 if (row.pid != 0) {
								 var actions = [];
								 actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.deptId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
								 actions.push('<a class="btn btn-info  btn-xs ' + addFlag + '" href="javascript:void(0)" onclick="$.operate.add(\'' + row.deptId + '\')"><i class="fa fa-plus"></i>新增</a> ');
								 actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.deptId + '\')"><i class="fa fa-trash"></i>删除</a>');
								 return actions.join('');
							 } else {
								 return "";
							 }
						 }
					 }]
			 };
			 $.treeTable.init(options);
		 });
	 </script>
</body>
</html>